package com.ferry.wallpaper.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ferry.wallpaper.mapper.CommentMapper;
import com.ferry.wallpaper.domain.Comment;
import com.ferry.wallpaper.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> get(Long wallId) {
        QueryWrapper<Comment> wrapper =
                new QueryWrapper<Comment>().eq("WALL_ID",wallId);
        return commentMapper.selectList(wrapper);
    }

    @Override
    public boolean insert(Long wallId, Long userId,String username, String text) {
        Comment comment = new Comment();
        comment.setUserId(userId);
        comment.setWallId(wallId);
        comment.setUserName(username);
        comment.setText(text);
        return commentMapper.insert(comment) > 0;
    }
}
